// https://leetcode.cn/problems/binary-tree-tilt/
// Created by ade on 2022/8/9.
//

class Solution {
public:
    int sum = 0;

    int findTilt(TreeNode *root) {
        dfs(root);
        return sum;
    }

    int dfs(TreeNode *node) {
        if (!node) return 0;
        int left = dfs(node->left);
        int right = dfs(node->right);
        sum += abs(left - right);
        return left + right + node->val;
    }


};

int main() {

}